﻿using System;
using System.Collections;
using System.Collections.Generic;

using System.Text;
using System.Web.UI.WebControls;

namespace Module.Core.BusinessLogic.CmsContents
{
    public class ModulType
    {
        public const int LEFTSIDE = 1;
        public const int RIGHTSIDE = 2;

        private int _ModuleType;
        public int ModuleType
        {
            get { return _ModuleType; }
            set { _ModuleType = value; }
        }
        private string _ModuleName;
        public string ModuleName
        {
            get { return _ModuleName; }
            set { _ModuleName = value; }
        }

        private string _ModuleUrl;
        public string ModuleUrl
        {
            get { return _ModuleUrl; }
            set { _ModuleUrl = value; }
        }

        public class TrangChu
        {
            public static int Type = 1;
            public static string TypeName = "Trang chủ";
            public static string Url = "trang-chu";
        }
        public class TinTuc
        {
            public static int Type = 2;
            public static string TypeName = "Tin tức";
            public static string Url = "tin-tuc";
        }      
        public class SanPham
        {
            public static int Type =3;
            public static string TypeName = "Module Sản phẩm";
            public static string Url = "san-pham";
        }                
        
        public class LinkUrl
        {
            public static int Type = 7;
            public static string TypeName = "Đặt Link Url";
        }       
        

        #region AddDropList
        public static ArrayList Modul()
        {
            ArrayList _Modul = new ArrayList(15);

            ModulType md = new ModulType();
            _Modul.Clear();
            md.ModuleType = TrangChu.Type;
            md.ModuleName = TrangChu.TypeName;
            md.ModuleUrl = TrangChu.Url;
            _Modul.Add(md);

            md = new ModulType();
            md.ModuleType = TinTuc.Type;
            md.ModuleName = TinTuc.TypeName;
            md.ModuleUrl = TinTuc.Url;
            _Modul.Add(md);

            md = new ModulType();
            md.ModuleType = SanPham.Type;
            md.ModuleName = SanPham.TypeName;
            md.ModuleUrl = SanPham.Url;
            _Modul.Add(md);            

            md = new ModulType();
            md.ModuleType = LinkUrl.Type;
            md.ModuleName = LinkUrl.TypeName;
            _Modul.Add(md);           
            
           return _Modul;
        }

        public static void AddDropList(ListControl DropList)
        {
            for (int i = 0; i < Modul().Count; i++)
            {
                DropList.Items.Add(new ListItem(((ModulType)Modul()[i]).ModuleName, ((ModulType)Modul()[i]).ModuleType.ToString()));
            }
        }
        #endregion

        #region GetType
        public static string GetType(string Key)
        {
            for (int i = 0; i < Modul().Count; i++)
            {
                if (((ModulType)Modul()[i]).ModuleUrl != null)
                {
                    if (((ModulType)Modul()[i]).ModuleUrl.ToLower() == Key.ToLower())
                    {
                        return ((ModulType)Modul()[i]).ModuleType.ToString();
                    }
                }
            }
            return "1";
        }
        #endregion

        #region GetUrl
        public static string GetUrl(int _Type)
        {
            for (int i = 0; i < Modul().Count; i++)
            {
                if (((ModulType)Modul()[i]).ModuleType == _Type)
                {
                    return ((ModulType)Modul()[i]).ModuleUrl.ToString();
                }
            }
            return "trang-chu";
        }
        #endregion

        #region Get ModulName
        public static string GetName(int type)
        {
            for (int i = 0; i < Modul().Count; i++)
            {
                if (((ModulType)Modul()[i]).ModuleType == type)
                {
                    return ((ModulType)Modul()[i]).ModuleName;
                }
            }
            return "Trang khác";
        }
        #endregion
    }
}
